<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <title>CryptoJS Test Suite</title>

        <!-- CryptoJS -->
        <script src="../src/core.js"></script>
        <script src="../src/lib-typedarrays.js"></script>

        <script src="../src/enc-base64.js"></script>
       
        <script src="../src/cipher-core.js"></script>
        <script src="../src/mode-ecb.js"></script>
        <script src="../src/aes.js"></script>

        <!-- YUI -->


        <!-- Tests -->
    

        <!-- Test runner -->
        <script>
           var key = CryptoJS.enc.Utf8.parse("8NONwyJtHesysWpM");
 
            var plaintText = 'ABCDEFGH'; // 明文
//  key你定义加密的方法  plaintText 传入的内容
        var encryptedData = CryptoJS.AES.encrypt(plaintText, key, {
        mode: CryptoJS.mode.ECB,
        padding: CryptoJS.pad.Pkcs7
        });
 
    console.log("加密前："+plaintText);
    console.log("加密后："+encryptedData);
 
// 加密码后的数据解密
    encryptedData = encryptedData.ciphertext.toString();

    var encryptedHexStr = CryptoJS.enc.Hex.parse(encryptedData);
    //key你自定义解密的方法与加密一样  encryptedBase64Str传入要解密的数据
    var encryptedBase64Str = CryptoJS.enc.Base64.stringify(encryptedHexStr);
    var decryptedData = CryptoJS.AES.decrypt(encryptedBase64Str, key, {
        mode: CryptoJS.mode.ECB,
        padding: CryptoJS.pad.Pkcs7
    });
//  解完密后的数据
    var decryptedStr = decryptedData.toString(CryptoJS.enc.Utf8);
 
    console.log("解密后:"+decryptedStr);
 
	
	//  var pwd = "PCsUFtgog9/qpqmqXsuCRQ==";
    // //加密服务端返回的数据
    // var decryptedData = CryptoJS.AES.decrypt(pwd, key, {
    //     mode: CryptoJS.mode.ECB,
    //     padding: CryptoJS.pad.Pkcs7
    // });
	
	// console.log("解密服务端返回的数据:"+decryptedStr);

        </script>

        <style>
            body.yui3-skin-sam .yui3-console-entry-meta,
            body.yui3-skin-sam .yui3-console-entry-content {
                display: inline-block;
                vertical-align: top;
            }
            body.yui3-skin-sam .yui3-console-entry-cat {
                display: inline-block;
                width: 35px;
                text-align: center;
            }
            body.yui3-skin-sam .yui3-console-entry {
                min-height: 0;
            }
        </style>
    </head>
    <body class="yui3-skin-sam">
    </body>
</html>
